package main

import (
	"github.com/prometheus/client_golang/prometheus"
	"log"
	"net/http"

	"github.com/prometheus/client_golang/prometheus/promhttp"
)

var (
	requestTotalVec = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "proxy_backend_requests_total",
			Help: "Total number of scrapes by proxy backend HTTP host",
		},
		[]string{"host", "path", "code"},
	)

	requestDurationVec = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "proxy_backend_requests_duration_seconds",
			Help:    "proxy backend processing duration distribution",
			Buckets: []float64{0.1, 0.3, 0.5, 0.7, 1},
		},
		[]string{"host", "path"},
	)
)

func main() {

	prometheus.Register(requestDurationVec)
	prometheus.Register(requestTotalVec)
	// The Handler function provides a default handler to expose metrics
	// via an HTTP server. "/metrics" is the usual endpoint for that.
	http.Handle("/metrics", promhttp.Handler())
	log.Fatal(http.ListenAndServe(":8080", nil))

}
